Modeling Time-Variation Over the Business Cycle (1960-2017): An International Perspective

Enrique Martinez-Garcia
Federal Reserve Bank of Dallas and SMU
emg.economics@gmail.com
Date: 10/1/2018
      


These codes have been adapted to compute turning points (classical cycles) as in Harding and Pagan (2002) and a recession index with data on real GDP (RGDP). 
The code also computes a concordance index and a correlation coefficient across cycles. The primary output is the recession index as it serves to document 
phases of contraction for quarterly real GDP for a large sample of countries. 

The data is employed to create the charts that describe global cycles. Therefore, the matlab code also produces an adjusted version of the recession 
index that can be easily plotted in a recession bar graph in excel. In any case, the code is flexible enough that can be applied to other datasets as well 
with only minor modifications.

The code HPdatingRGDP_balanced.m works with balanced panels where all the series start and end at the same time or are converted to start and end at the same 
time. The code HPdatingRGDP_unbalanced.m is designed to handle unbalanced panels and can be used whenever some series start and/or end at different times, 
preserving that.


LIST OF CODES AND FILES:

> Main matlab code for the computation of classical cycles:

	HPdatingRGDP_balanced.m
	HPdatingRGDP_unbalanced.m

> Supplementary matlab functions used for dating classical cycles together with HPdatingRGDP_balanced.m and HPdatingRGDP_unbalanced.m:

	indicat.m
	isdate.m
	meanc.m
	rawall.m
	rows.m
	states.m
	sumc.m

> Input and output file (excel file) where the original data on real GDP is stored and the classical cycles' indicators are saved:

	RGDP_cycles.xlsx

> The primary sources for the data on real GDP can be found are:

	G8data.7.1.2018_GDP&Deflator.xlsx


INSTRUCTIONS :

This excel file plots classical cycles (peak-to-trough) for real GDP (RGDP) for all countries for which there is data during the post-WWII period using matlab code for dating the cycle.

> The original data comes from the OECD - Quarterly National Accounts (Obtained via Haver Analytics)
    >> The data used to determine the classical cycles constitutes a balanced panel and can be found summarizes in the spreadsheet DATA.

> The classical cycles are computed with Harding and Pagan's (2002) variant of the Bry-Boschan business cycle dating methodology.
    >> The turning points are determined by the following rule (which can be modified if necessary):
          peak : must be greater than 'turnphase' (2 quarters for real GDP) on either side.
          trough : must be smaller than 'turnphase' (2 quarters for real GDP) on either side.
        A turning point must meet some additional criteria (restrictions):   
          Each 'phase' (contraction/expansion) lasts at least 2 quarters for real GDP.
          Each full 'cycle' phase (contraction & expansion) lasts at least 4 quarters for real GDP.
          Troughs and peaks must alternate : if there are two peaks (troughs) in a row, it will select the highest (lowest).
          Each trough must be lower than the preceeding peak.
          There are no turning points within 'phase' length end points (2 quarters for real GDP).
    >> The classical cycles are computed with the matlab codes HPdatingRGDP_balanced.m and/or HPdatingRGDP_unbalanced.m (created with Matlab R2012a (7.14.0.739)).
          HPdatingRGDP_balanced.m -- if the original data does not form a balanced panel, then only the time series span for which all series are complete will be included. (NOT USED WITH THIS BALANCED-PANEL DATASET).
          HPdatingRGDP_unbalanced.m -- if the original data does not form a balanced panel, then each time series will be investigated over its own (different) sample. (USED WITH THIS BALANCED-PANEL DATASET).
    >> The primary output of the matlab codes HPdatingRGDP_balanced.m and HPdatingRGDP_unbalanced.m is a dummy variable that takes the value of one from peak to trough and zero otherwise. 
          * The matlab code automatically uploads the data from the spreadsheet DATA and stores the classical cycles it has extracted in the spreadsheet CYCLES.
    >> This excel file (RGDP_cycles.xlsx) needs to be saved in the same folder that the codes HPdatingRGDP_balanced.m, HPdatingRGDP_unbalanced.m and its complementary matlab functions, 
          but there is no need to change it otherwise because the uploading of data and the storing of the output (the contraction indicator and the transformed indicator for the recession bar plot)
          is all done AUTOMATICALLY.

UPDATING :

1. The matlab code uploads data from the spreadsheets DATA. We must check that all countries have some numeric observations.
     We must also check that the first column is reserved for the dates and the first two rows are reserved for the short and long names of the series.
2. For the code to work properly, we must ensure that the ordering of the countries remains the same in DATA.
    We must also check that the same ordering is applied to CYCLES.
    These spreadsheets must also follow the rule that reserves the first column for dates and the first two rows for the short and the long names of the series.
3. If more quarters are included in the sample, then we have to extend the links that pull the information for the quarters 
     in the spreadsheet CYCLES.
4. We have to modify the matlab code HPdatingRGDP_balanced.m and HPdatingRGDP_unbalanced.m as needed: 
     - To adjust the 'turnphase', 'phase', and 'cycle' if we want to consider alternative specifications of the classical cycle.
     Changes in the length of the series do not require a change in the matlab code. The code is flexible enough that it will AUTOMATICALLY upload 
     all available data and then will AUTOMATICALLY store the recession indicators for each one of the series uploaded. Missing observations are marked with NA's.
5. Type HPdatingRGDP_balanced or HPdatingRGDP_unbalanced in matlab's command window in order to run the code.
     -- The default options will calculate classical cycles on real GDP. The classical cycles will be automatically stored in the spreadsheets CYCLES.
